package main

import (
	"flag"
	"go-block-1/server"
	"log"
	"net/http"
)

func main() {
	var port string
	flag.StringVar(&port,"port","8111","端口号")
	flag.Parse()
	log.Println("server will be start at port :"+ port)
	http.HandleFunc("/transactions/new",server.NewTrabsaction)
	http.HandleFunc("/mine",server.Mine)
	http.HandleFunc("/chain",server.FullChain)
	http.HandleFunc("/nodes/register",server.NodeRegister)
	http.HandleFunc("/nodes/resolve",server.ResolveConfict)

	err := http.ListenAndServe("127.0.0.1:"+ port,nil)

	if err != nil {
		log.Fatal("ListenAndServe:",err.Error())
	}
}
